<template>
  <div>
    <div class="userimgs">
      <div class="userimg">
        <img src />
        <!-- data.user.avatar -->
      </div>
      <span class="usertitle">{{data.user?.nickName}}的主页</span>
    </div>
    <div class="middle">
      <router-link to="/leave">
        <i class="iconfont icon-hrattendanceleave"></i>
        <p>请假管理</p>
      </router-link>
      <router-link to="/work">
        <i class="iconfont icon-kaoqinchuqin"></i>
        <p>考勤</p>
      </router-link>
      <router-link to="/cards">
        <i class="iconfont icon-yiqiatong"></i>
        <p>一卡通</p>
      </router-link>
    </div>
    <div class="footer">
      <div class="items" @click="gotoEidt">
        <span class="iconfont icon-xiugaidingdan"></span>
        <span class="itemtitle">个人信息</span>
      </div>
      <div class="items" @click="gofeed">
        <span class="iconfont icon-yijianfankui"></span>
        <span class="itemtitle">意见反馈</span>
      </div>
      <div class="items">
        <span class="iconfont icon-guanyu"></span>
        <span class="itemtitle">关于</span>
      </div>
      <div class="items" @click="goamendpwd">
        <span class="iconfont icon-xiugaidingdan"></span>
        <span class="itemtitle">修改密码</span>
      </div>
      <div class="items" @click="tuichu">
        <span class="iconfont icon-tuichudenglu"></span>
        <span class="itemtitle">退出登录</span>
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted, reactive } from "vue";
import { detail } from "../model/userModel";
import { useRouter } from "vue-router";
let emit = defineEmits(["getItemSe"]);
let router = useRouter();

let data = reactive({
  user: {}
});
let gofeed = () => {
  router.push("/feedback");
};
let gotoEidt = () => {
  router.push("/edituser");
};
let goamendpwd = () => {
  router.push("/amendpwd");
};
let tuichu = () => {
  // router.push("/mine");
  location.reload();
  window.localStorage.removeItem("token");
  window.localStorage.removeItem("worktime");
  emit('getItemSe')
};
onMounted(() => {
  detail(
    {},
    {
      Authorization: window.localStorage.getItem("token")
    }
  ).then(res => {
    console.log(res);
    data.user = res.data.user;
  });
});
</script>

<style lang="scss">
.userimgs {
  width: 100%;
  height: 170px;
  background-color: #1989fa;
  border-bottom: 5px solid #eee;
  display: flex;
  .usertitle {
    font-size: 20px;
    color: #ffffff;
    line-height: 170px;
    margin-left: 20px;
  }
  .userimg {
    width: 70px;
    height: 70px;
    margin-top: 50px;
    margin-left: 20px;
    border-radius: 50%;
    background-color: #fff;
  }
}
.middle {
  width: 100%;
  height: 70px;
  line-height: 30px;
  border-bottom: 10px solid #eee;
  display: flex;
  justify-content: center;
  align-items: center;

  a {
    flex: 1;
    text-decoration: none;
    text-align: center;
    font-size: 14px;
    color: rgba(81, 76, 76, 0.667);

    p {
      font-size: 14px;
    }
  }
}
.items {
  width: 95%;
  height: 50px;
  border-bottom: 1px solid #eee;
  font-size: 16px;
  text-align: left;
  line-height: 50px;
  padding-left: 15px;
  box-sizing: border-box;
  background-color: #ffffff;
  .itemtitle {
    color: rgba(81, 76, 76, 0.667);
    margin-left: 10px;
  }
}
</style>